package net;

import android.util.Log;

import com.lefull.lefullbase.utils.OkGoHelper.ParserBaseModel;
import com.lefull.lefullbase.utils.OkGoHelper.ResponseEntity;

import org.json.JSONObject;

public class TenantParserModel extends ParserBaseModel {

    public ResponseEntity parserModelResponse(String jsonString) {
        super.parserModelResponse(jsonString);
        Log.i("login", "parserModelResponse: "+jsonString);
        try {
            JSONObject jsonObject = this.parserJSONObject();
            if (jsonObject.getInt("status") == 1) {
                ResponseEntity tmpEntity = new ResponseEntity(jsonObject.getInt("status"),
                        jsonObject.getString("message"),
                        jsonObject.get("data").toString());
                Log.i("login", "parserModelResponse: "+jsonString);
                return tmpEntity;
            } else {
                return new ResponseEntity(0, jsonObject.getString("message"), jsonObject.get("data").toString());
            }
        } catch (Throwable t) {
            Log.e("", t.getMessage());
            //TODO:JSON解析异常
            return new ResponseEntity(0, "返回数据字段异常", "");
        }
    }
}
